package com.linhh.mall.center.server.service;

import com.linhh.mall.center.api.TbLandCoordinateService;
import com.linhh.mall.center.common.pojo.TbLandCoordinate;
import com.linhh.mall.center.common.pojo.UserInfo;
import com.linhh.mall.center.server.mappers.TbLandCoordinateMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @Author linhh
 * @Date 2023 03 20 13 56
 **/
@Service
public class TbLandCoordinateServiceImpl implements TbLandCoordinateService {

    @Autowired
    private TbLandCoordinateMapper tbLandCoordinateMapper;

    @Override
    public List<TbLandCoordinate> selectAll() {
        return tbLandCoordinateMapper.selectAll();
    }

    @Override
    public int addTbLandCoordinate(TbLandCoordinate tbLandCoordinate) {
        tbLandCoordinateMapper.insertUseGeneratedKeys(tbLandCoordinate);
        return 1;
    }

    @Override
    public int deleteTbLandCoordinate(Long id) {
        tbLandCoordinateMapper.deleteByPrimaryKey(id);
        return 1;
    }

    @Override
    public int updateTbLandCoordinate(TbLandCoordinate tbLandCoordinate) {
        tbLandCoordinateMapper.updateByPrimaryKeySelective(tbLandCoordinate);
        return 1;
    }

    @Override
    public TbLandCoordinate selectCoordinateById(Long id) {
        return tbLandCoordinateMapper.selectByPrimaryKey(id);
    }

    @Override
    public TbLandCoordinate selectCoordinateByLandId(Long landId) {
        Example example = new Example(TbLandCoordinate.class);
        example.createCriteria().andEqualTo("landId", landId);
        TbLandCoordinate tbLandCoordinate = tbLandCoordinateMapper.selectOneByExample(example);
        return tbLandCoordinate;
    }

}
